#include <iostream>
#include <stack>
#include <string>

bool isValidSequence(const std::string& sequence) {
    std::stack<char> stack;
    std::string opening = "([{<";
    std::string closing = ")]}>";
    
    for (char c : sequence) {
        if (opening.find(c) != std::string::npos) {
            stack.push(c);
        } else if (closing.find(c) != std::string::npos) {
            if (stack.empty() || opening.find(stack.top()) != closing.find(c)) {
                return false;
            }
            stack.pop();
        }
    }
    
    return stack.empty();
}

int main() {
    std::string sequence;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> sequence;
    
    if (isValidSequence(sequence)) {
        std::cout << "True" << std::endl;
    } else {
        std::cout << "False" << std::endl;
    }
    
    return 0;
}